<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	/* pageContext.setAttribute("fnId", request.getAttribute("fnId"));
	pageContext.setAttribute("userPwoer", request.getSession().getAttribute("userPwoer")); */
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body class="gray-bg">
	<nav class="huiNav">
		<i class="fa fa-home"></i> 首页 <span>&gt;</span><span>&gt;</span>客户列表
		<a class="btn btn-info  btn-sm pull-right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="fa fa-refresh"></i></a>
	</nav>

	<div class="ibox-content">
		<!-- 搜索框部分start -->
		<%-- <p:btn value="serch"> --%>
			<form class="form-inline" id="serchform">
				<div class="form-group mr-20">
					<label for="exampleInputName2">公司名称</label> 
					<input name="companyName"
						type="text" class="form-control">
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">联系人</label> 
					<input name="contactName"
						type="text" class="form-control">
				</div><!-- 
				<div class="form-group mr-20">
					<label for="exampleInputName2">联系人职位</label> 
					<input name="contactTel"
						type="text" class="form-control">
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">联系方式</label> 
					<input name="companyTel"
						type="text" class="form-control">
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">公司地址</label> 
					<input name="address"
						type="text" class="form-control">
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">业务往来</label> 
					<input name="introduction"
						type="text" class="form-control">
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">备注</label> 
					<input name="remark"
						type="text" class="form-control">
				</div>
				<div class="form-group mr-20">
					<label for="exampleInputName2">附件</label> 
					<input name="optionId"
						type="text" class="form-control">
				</div> -->
				<button onclick="myGrid.serchData()" type="button"
					class="btn btn-info btn-sm">
					<i class="fa fa-search "></i> 搜索
				</button>
				<button type="reset" class="btn btn-info btn-sm">
					<i class="fa fa-refresh "></i> 重置
				</button>
			</form>
		<%-- </p:btn> --%>
		<!-- 搜索框部分en -->
		<div class="option-bar">
			<%-- <p:btn value="dels"> --%>
				<button onclick="myGrid.delItems()" type="button"
					class="btn btn-danger btn-sm">
					<i class="fa fa-trash"></i>批量删除
				</button>
			<%-- </p:btn>
			<p:btn value="add"> --%>
				<button onclick="openAdd()" type="button"
					class="btn btn-success btn-sm">
					<i class="fa fa-plus"></i> 新增
				</button>
			<%-- </p:btn> --%>
		</div>
		<table id="mgrid">
			<thead>
				<tr>
					<th data-checkbox="true"></th>
					<th data-formatter="MGrid.indexfn" data-align="center"
						data-width="30px">序号</th>
					<th data-field="companyName" data-sortable="true">公司名称</th>
					<th data-field="contactName">联系人</th>
					<th data-field="contactTel">联系职位</th>
					<th data-field="companyTel">联系方式</th>
					<th data-field="address">公司地址</th>
					<th data-field="introduction">业务往来</th>
					<th data-field="remark">备注</th>
					<th data-field="fileUrl">附件</th>
					<th data-field="account">客户账号</th>
					<th data-align="center" data-width="150px" data-field="id"
						data-formatter="buidOperate">操作</th>
				</tr>
			</thead>
		</table>
	</div>

	<script type="text/javascript">
		var myGrid;
		$(function() {
			//有删除权限
			var delUrl = "";
			delUrl = "${path}/admin/client/del";

			myGrid = MGrid.initGrid({
				url : "${path}/admin/client/showList",
				delUrl : delUrl
			});

			//初始化操作
			MTools.autoFullSelect();

		});
		function buidOperate(value, row, index) {
			var html = '';
			html += '<button class="btn btn-default btn-sm mr-5" onClick="openEdit('
					+ value
					+ ')"  title="编辑"><i class="fa fa-edit"></i></buttoun>'
			html += '<button class="btn btn-default btn-sm" onClick="myGrid.delItem('
					+ value
					+ ')" title="删除"><i class="fa fa-lg fa-trash-o"></i></buttoun>';
			html += ''
			return html;
		}
		//打开添加界面
		function openAdd() {
			layer.full(
			layer.open({
				type : 2,
				title : "添加客户",
				area : [ MUI.SIZE_L, '500px' ],
				maxmin : true,
				content : [ '${path}/admin/client/editForm' ]
			}));
		}

		//打开编辑界面
		function openEdit(id) {
			layer.full(
			layer.open({
				type : 2,
				title : "编辑客户",
				area : [ MUI.SIZE_L, '500px' ],
				maxmin : true,
				content : [ '${path}/admin/client/editForm?id=' + id ]
			}));
		}
	</script>
</body>
</html>
